package com.moto.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.moto.entity.CarBrand;
import com.moto.entityDto.CarBrandDto;
import com.moto.entityDto.CarBrandLikeDto;
import com.moto.mapper.CarBrandMapper;
import com.moto.service.ICarBrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moto.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 摩托车品牌表 服务实现类
 * </p>
 *
 * @author hyf
 * @since 2023-08-29
 */
@Service
public class CarBrandServiceImpl extends ServiceImpl<CarBrandMapper, CarBrand> implements ICarBrandService {


    @Autowired
    private CarBrandMapper carBrandMapper;

    /**
     * 根据修改摩托车信息
     * @param carBrandDTO
     * @return
     */
    @Override
    public void updateCarBrand(CarBrandDto carBrandDTO) {
        carBrandMapper.updateCarBrand(carBrandDTO);
    }


    /**
     * 模糊查询车辆品牌
     * @param carBrandLikeDto
     * @return
     */
    @Override
    public PageResult likeCarBrand(CarBrandLikeDto carBrandLikeDto) {
        PageHelper.startPage(carBrandLikeDto.getPage(),carBrandLikeDto.getPageSize());
        Page<CarBrand> page = carBrandMapper.likeCarBrand(carBrandLikeDto);
        return new PageResult(page.getTotal(),page.getResult());
    }

}
